#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>


char map[105][105] = { 0 };
int main()
{
	int n, m, digit = 0;
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			scanf("\n%c", &map[i][j]);
		}
		
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			digit = 0;
			if (map[i][j] == '*')continue;
			if (map[i][j + 1] == '*')digit++;
			if (map[i][j - 1] == '*')digit++;
			if (map[i + 1][j] == '*')digit++;
			if (map[i - 1][j] == '*')digit++;
			if (map[i - 1][j + 1] == '*')digit++;
			if (map[i + 1][j + 1] == '*')digit++;
			if (map[i - 1][j - 1] == '*')digit++;
			if (map[i + 1][j - 1] == '*')digit++;
			map[i][j] = digit;
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			if (map[i][j] == '*')printf("*");
			else printf("%d", map[i][j]);
		}
		printf("\n");
	}
	return 0;
}